﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Kokomo.PeInspector.ObjectGraphs
{
	class ChoiceNodeTemplate<TObject> : NodeTemplate<TObject>
	{
		public ChoiceNodeTemplate(
			IEnumerable<NodeTemplate<TObject>> choices
			)
		{
			if (choices == null) throw new ArgumentNullException("choices");
			this.Choices = choices;
		}

		public IEnumerable<NodeTemplate<TObject>> Choices { get; private set; }

		public override bool Inspect(object value)
		{
			bool matches = false;

			foreach (var choice in this.Choices)
			{
				if (choice != null)
				{
					matches |= choice.Inspect(value);
				}
			}

			return matches;
		}
	}
}
